<?php
Class Get_db extends CI_Model{
	function getAll(){
		$query= $this->db->query("select * from top10score order by point desc");
		return $query->result();
	}
	function update($data,$name){
		$this->db->where('name',$name);
		$this->db->update('top10score',$data);
	}
	function insert($data){
		$this->db->insert('top10score',$data);
	}
	function count_all(){
		return $this->db->count_all('top10score');
	}
	function check_exists($name){
		$query= $this->db->query("select * from top10score where name='".$name."'");
		return $query->result();
	}
	function delete_min(){	
		$query= $this->db->query("select min(point)as min from top10score");
		$min = 0;
		foreach ($query->result() as $row)
		{
		    $min=  $row->min;
		}

		$this->db->where('point',$min);
		$this->db->delete('top10score');
		
	}
} 
?>